public class CustomCompanyLookupController 
{
    public Account act {get;set;} // new account to create
    public List<Account> results{get;set;} // search results
    public string searchString{get;set;} // search keyword
 
    public CustomCompanyLookupController() 
    {
        act = new Account();
        // get the current search string
        searchString = System.currentPageReference().getParameters().get('lksrch');
        runSearch();  
    }
 
    // performs the keyword search
    public PageReference search() 
    {
        runSearch();
        return null;
    }
 
    // prepare the query and issue the search command
    private void runSearch() 
    {
        // TODO prepare query string for complex serarches & prevent injections
        results = performSearch(searchString);               
    } 
 
    // run the search and return the records found. 
    private List<Account> performSearch(string searchString) 
    {
        String soql = 'SELECT id, name FROM Account';
        if(searchString != '' && searchString != null)
        {
            soql = soql +  ' WHERE name LIKE \'' + searchString +'%\'';
        }
        soql = soql + ' limit 50';
        System.debug(soql);
        return database.query(soql); 
    }
  
    // used by the visualforce page to send the link to the right dom element
    public string getFormTag() 
    {
        return System.currentPageReference().getParameters().get('frm');
    }
 
    // used by the visualforce page to send the link to the right dom element for the text box
    public string getTextBox() 
    {
        return System.currentPageReference().getParameters().get('txt');
    }
    
    public static testMethod void testMyController() 
    {
       CustomCompanyLookupController controller = new CustomCompanyLookupController();
       
       PageReference Pg;
       Pg = controller.search();
       String formTag  = controller.getFormTag();
       String textBox = controller.getTextBox();  
    }
}